home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / pygtk-2.0 / pygtk / pygtk.h
Encoding:
C/C++ Source or Header  |  2006-01-20  |  2.2 KB  |  82 lines

  1. /* -*- Mode: C; c-basic-offset: 4 -*- */
  2. #ifndef _PYGTK_H_
  3. #define _PYGTK_H_
  4.  
  5. #define NO_IMPORT_PYGOBJECT
  6. #include <pygobject.h>
  7. #include <Python.h>
  8. #include <gtk/gtk.h>
  9.  
  10. struct _PyGtk_FunctionStruct {
  11.     char *pygtkVersion;
  12.  
  13.     PyTypeObject *gdkAtom_type;
  14.     PyObject *(* gdkAtom_new)(GdkAtom atom);
  15.     gboolean  (* rectangle_from_pyobject)(PyObject     *object,
  16.                       GdkRectangle *rectangle);
  17. };
  18.  
  19. /* structure definitions for the various object types in PyGTK */
  20. typedef struct {
  21.     PyObject_HEAD
  22.     gchar *name;
  23.     GdkAtom atom;
  24. } PyGdkAtom_Object;
  25.  
  26. /* routines to get the C object value out of the PyObject wrapper */
  27. #define PyGdkAtom_Get(v) (((PyGdkAtom_Object *)(v))->atom)
  28.  
  29. /* this section is dependent on whether we are being included from gtkmodule.c
  30.  * or not.  A similar source level interface should be provided in both
  31.  * instances. */
  32. #ifndef _INSIDE_PYGTK_
  33.  
  34. /* for multi file extensions, define one of these in all but the main file
  35.  * of the module */
  36. #if defined(NO_IMPORT) || defined(NO_IMPORT_PYGTK)
  37. extern struct _PyGtk_FunctionStruct *_PyGtk_API;
  38. #else
  39. struct _PyGtk_FunctionStruct *_PyGtk_API;
  40. #endif
  41.  
  42. /* type objects */
  43. #define PyGdkAtom_Type          *(_PyGtk_API->gdkAtom_type)
  44.  
  45. /* type checking routines */
  46. #define PyGdkAtom_Check(v) ((v)->ob_type == _PyGtk_API->gdkAtom_type)
  47.  
  48. /* type objects */
  49. #define PyGdkAtom_New          (_PyGtk_API->gdkAtom_new)
  50.  
  51. /* some variables */
  52. #define PYGTK_VERSION (_PyGtk_API->pygtkVersion)
  53.  
  54. /* public functions */
  55. #define pygdk_rectangle_from_pyobject (_PyGtk_API->rectangle_from_pyobject)
  56.  
  57.  
  58. /* a function to initialise the pygtk functions */
  59. #define init_pygtk() { \
  60.     PyObject *pygtk = PyImport_ImportModule("gtk._gtk"); \
  61.     if (pygtk != NULL) { \
  62.     PyObject *module_dict = PyModule_GetDict(pygtk); \
  63.     PyObject *cobject = PyDict_GetItemString(module_dict, "_PyGtk_API"); \
  64.     if (PyCObject_Check(cobject)) \
  65.         _PyGtk_API = (struct _PyGtk_FunctionStruct*) \
  66.         PyCObject_AsVoidPtr(cobject); \
  67.     else { \
  68.             PyErr_SetString(PyExc_RuntimeError, \
  69.                             "could not find _PyGtk_API object"); \
  70.         return; \
  71.         } \
  72.     } else { \
  73.         PyErr_SetString(PyExc_ImportError, \
  74.                         "could not import gtk._gtk"); \
  75.         return; \
  76.     } \
  77. }
  78.  
  79. #endif
  80.  
  81. #endif /* !_PYGTK_H_ */
  82.